From: tsteven4 Date: Thu, 28 Feb 2019 14:14:13 +0000 (-0700) Subject: Refactor application packaging for linux/macos. (#310) X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~8^2~34 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=cdbf84c30e43df5902260da44903b271c4912a09;p=gpsbabel.git Refactor application packaging for linux/macos. (#310) * Refactor application packaging for linux/macos. Packaging of the GUI for linux/macos can now be done either by building the make target "package" created by "qmake app.pro", or by executing a bash script "package_app". Packaging with the legacy configure flow will build the package target. Travis CI scripts will build the package target. The obsolete script mac-localize is deleted. This functionality is included in package_app. The obsolete script makelinuxdist.sh is deleted. We have not distributed a linux package in some time. Furthermore this scirpt hadn't worked in some time. package_app does not create a standalone linux app, however it packages all the bits from GPSBabel in GPSBabelFE. This makes creating a Docker app, which includes the Qt installation, for GPSBabel easy. Merge relevant Qt .qm files into one qt_xx.qm file for each language as recommended by Qt. Deploy these meged .qm files with linux/macos builds. Since Qt5 we only deployed the meta catalog, but not it's dependencies. This should have led to the dependencies not being available without Qt being installed. gpsbabel.qm and gpsbabelfe.qm are no longer included in the packaged apps for windows/linux/macos, as it should be. --- diff --git a/.travis.yml b/.travis.yml index ce5fac232..eed6b17df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ script: after_success: - cd ${TRAVIS_BUILD_DIR} # only deploy pushes to master or prs that target master. the prs will go to transfr.sh, the pushes go to github. - - if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "${QT_VERSION}" = "5.12.1" ] && [ "$TRAVIS_BRANCH" = "master" ]; then bash ./tools/uploadtool/upload.sh gui/objects/GPSBabel-*.dmg; fi + - if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "${QT_VERSION}" = "5.12.1" ] && [ "$TRAVIS_BRANCH" = "master" ]; then bash ./tools/uploadtool/upload.sh gui/GPSBabel-*.dmg; fi branches: except: diff --git a/GPSBabel.pro b/GPSBabel.pro index 7864f543b..95433e059 100644 --- a/GPSBabel.pro +++ b/GPSBabel.pro @@ -15,7 +15,11 @@ if(equals(QT_MAJOR_VERSION, $$MIN_QT_VERSION_MAJOR):equals(QT_MINOR_VERSION, $$M QT -= gui -TARGET = GPSBabel +linux: { + TARGET = gpsbabel +} else { + TARGET = GPSBabel +} CONFIG += console CONFIG -= app_bundle CONFIG += c++14 diff --git a/Makefile.in b/Makefile.in index 857244d00..2b71ca4a2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -151,7 +151,7 @@ dep doc \ release-sourcecheck release-tarball release-rpm \ cross-configure \ release-winbuild release-upload mac-upload release rpm mac-release \ -gui linux-gui mac-gui mac-gui-dmg msvc-build test-release \ +gui linux-gui mac-gui test-release \ toolinfo all: gpsbabel$(EXEEXT) @@ -384,7 +384,7 @@ release-upload: /tmp/gpsbabel-$(VERSIOND).tar.gz /tmp/gpsbabel-$(VERSIOND).zip mac-upload: # gb_upload GPSBabel+-$(VERSIOND).dmg - gb_upload gui/objects/GPSBabel-$(VERSIOND).dmg + gb_upload gui/GPSBabel-$(VERSIOND).dmg release: release-sourcecheck release-tarball release-winbuild release-rpm release-upload @@ -394,33 +394,17 @@ rpm: changes.html gui: gpsbabel$(EXEEXT) cd gui ; $(QMAKE) app.pro && $(MAKE) $(MAKEFLAGS) - cd gui ; $(LUPDATE) app.pro - cd gui ; $(LRELEASE) app.pro linux-gui: gui - cd gui; ./makelinuxdist.sh - -mac-gui: gui - # file gpsbabel | grep '2 architectures' || exit 1 - # file gui/objects/GPSBabelFE.app/Contents/MacOS/GPSBabelFE | grep '2 architectures' || exit 1 - mkdir -p gui/objects/GPSBabelFE.app/Contents/MacOS/translations - cp gui/*.qm gui/objects/gpsbabelFE.app/Contents/MacOS/translations - cp gpsbabel gui/objects/GPSBabelFE.app/Contents/MacOS - cp -r gui/help/*.html gui/objects/GPSBabelFE.app/Contents/MacOS - cp gui/gmapbase.html gui/objects/GPSBabelFE.app/Contents/MacOS - tools/mac-localize + cd gui; $(MAKE) $(MAKEFLAGS) package # Build the Qt front end, place GPSBabel in the right place, deploy all # the libs. -mac-gui-dmg: mac-gui - rm -f gui/objects/GPSBabelFE.dmg - cd gui/objects ; macdeployqt GPSBabelFE.app -executable=GPSBabelFE.app/Contents/MacOS/gpsbabel -dmg - mv gui/objects/GPSBabelFE.dmg gui/objects/GPSBabel-$(VERSIOND).dmg - -msvc-build: - @#Intended for development. Assume .NET 4 is used - may require tweaks - "$(word 1, $(wildcard $(SYSTEMROOT)/Microsoft.NET/Framework/v4*/msbuild.exe))" msvc/GPSBabel.vcxproj /nologo /maxcpucount +mac-gui: gui + rm -f gui/GPSBabelFE.dmg + cd gui; $(MAKE) $(MAKEFLAGS) package + mv gui/GPSBabelFE.dmg gui/GPSBabel-$(VERSIOND).dmg # release check using CVS tree test-release: doc gpsbabel.html changes.html diff --git a/configure b/configure index e7a61b37d..376b4927d 100755 --- a/configure +++ b/configure @@ -6782,8 +6782,6 @@ as_dir=testo.d; as_fn_mkdir_p ac_config_files="$ac_config_files Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc" -ac_config_files="$ac_config_files gui/makelinuxdist.sh" - cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure @@ -7483,7 +7481,6 @@ do "xmldoc/makedoc") CONFIG_FILES="$CONFIG_FILES xmldoc/makedoc" ;; "tools/mkcapabilities") CONFIG_FILES="$CONFIG_FILES tools/mkcapabilities" ;; "win32/gpsbabel.rc") CONFIG_FILES="$CONFIG_FILES win32/gpsbabel.rc" ;; - "gui/makelinuxdist.sh") CONFIG_FILES="$CONFIG_FILES gui/makelinuxdist.sh" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -8034,11 +8031,6 @@ $as_echo "$as_me: $ac_file is unchanged" >&6;} esac - - case $ac_file$ac_mode in - "gui/makelinuxdist.sh":F) chmod +x gui/makelinuxdist.sh ;; - - esac done # for ac_tag diff --git a/configure.ac b/configure.ac index 55812e1b2..5130eac3c 100644 --- a/configure.ac +++ b/configure.ac @@ -445,5 +445,4 @@ AS_MKDIR_P([zlib/contrib/minizip]) AS_MKDIR_P([testo.d]) AC_CONFIG_FILES([Makefile gbversion.h gui/setup.iss xmldoc/makedoc tools/mkcapabilities win32/gpsbabel.rc]) -AC_CONFIG_FILES([gui/makelinuxdist.sh], [chmod +x gui/makelinuxdist.sh]) AC_OUTPUT diff --git a/gui/.gitignore b/gui/.gitignore index bb7243608..85ff478e1 100644 --- a/gui/.gitignore +++ b/gui/.gitignore @@ -1,7 +1,8 @@ /GPSBabel[0-9]*.[0-9]*.[0-9]*/ /GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2 +/GPSBabelFE/ +/GPSBabelFE.app/ /Makefile -/makelinuxdist.sh /objects/ /tmp/ /release/ diff --git a/gui/app.pro b/gui/app.pro index 7d2039b52..a10628b49 100755 --- a/gui/app.pro +++ b/gui/app.pro @@ -24,6 +24,7 @@ unix:DESTDIR = objects unix:MOC_DIR = objects unix:OBJECTS_DIR = objects unix:RCC_DIR = objects +mac:DESTDIR = . mac:LIBS += -framework IOKit -framework CoreFoundation unix { @@ -45,7 +46,7 @@ win32 { win32-g++ { QMAKE_LFLAGS_RELEASE += -static-libgcc } -unix:TARGET=gpsbabelfe-bin +unix:TARGET=gpsbabelfe mac:TARGET=GPSBabelFE FORMS += aboutui.ui @@ -117,6 +118,9 @@ TRANSLATIONS += gpsbabelfe_hu.ts TRANSLATIONS += gpsbabelfe_it.ts TRANSLATIONS += gpsbabelfe.ts - - - +macx|linux{ + package.commands = QMAKE=$(QMAKE) ./package_app + package.depends = $(TARGET) + QMAKE_EXTRA_TARGETS += package +} +linux: QMAKE_DISTCLEAN += -r GPSBabelFE diff --git a/gui/makelinuxdist.sh.in b/gui/makelinuxdist.sh.in deleted file mode 100644 index fa022a314..000000000 --- a/gui/makelinuxdist.sh.in +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -set -e -v -QT_INSTALL_PLUGINS=`@QMAKE@ -query QT_INSTALL_PLUGINS` -QT_INSTALL_TRANSLATIONS=`@QMAKE@ -query QT_INSTALL_TRANSLATIONS` - -DISTNAME=GPSBabel@PACKAGE_VERSION@@PACKAGE_RELEASE@ -DISTDIR=$DISTNAME -rm -rf $DISTDIR -mkdir $DISTDIR -mkdir $DISTDIR/plugins -mkdir $DISTDIR/translations - -QT_LIBS="`ldd objects/gpsbabelfe-bin | grep libQt | awk '{print $3}'`" -QT_LIBS="$QT_LIBS `ldd $QT_INSTALL_PLUGINS/platforms/libqxcb.so | grep libQt | awk '{print $3}'`" -for lib in $QT_LIBS -do - cp $lib $DISTDIR -done -#cp `ldd objects/gpsbabelfe-bin | grep libphonon |awk '{print $3}'` $DISTDIR -#cp `ldd objects/gpsbabelfe-bin | grep libaudio |awk '{print $3}'` $DISTDIR - -cp -r $QT_INSTALL_PLUGINS/imageformats $DISTDIR/plugins -if [ -e $QT_INSTALL_PLUGINS/codecs ] -then - cp -r $QT_INSTALL_PLUGINS/codecs $DISTDIR/plugins -else - echo "Warning: $QT_INSTALL_PLUGINS/codecs not found, perhaps this is normal for Qt5" -fi -if [ -e $QT_INSTALL_PLUGINS/platforms ] -then -# we need at least platforms/libqxcb.so - cp -r $QT_INSTALL_PLUGINS/platforms $DISTDIR/plugins -else - echo "Wanring: $QT_INSTALL_PLUGINS/platforms not found, this is normal for Qt4" -fi -cp $QT_INSTALL_TRANSLATIONS/qt_*.qm $DISTDIR/translations/ - -# copy the compiled translations -cp *.qm $DISTDIR/translations - -# Now our gui -cp gmapbase.html $DISTDIR/ -cp gpsbabelfe $DISTDIR/ -chmod +x $DISTDIR/gpsbabelfe -cp objects/gpsbabelfe-bin $DISTDIR -cp qt.conf $DISTDIR/ -cp ../gpsbabel $DISTDIR/ - -cp ../COPYING $DISTDIR/ -#cp AUTHORS $DISTDIR/ -cp ../README* $DISTDIR/ - - -rm -f $DISTDIR.tar $DISTDIR.tar.bz2 -tar cvf $DISTDIR.tar $DISTDIR -bzip2 $DISTDIR.tar - diff --git a/gui/package_app b/gui/package_app new file mode 100755 index 000000000..fcc7e6fbb --- /dev/null +++ b/gui/package_app @@ -0,0 +1,120 @@ +#!/bin/bash -e +# +# package GUI application +# + +function convert_qt_translations() +{ +# Combine the Qt translation files we use into local qt_??.qm files. +# +# It is recommended to combine Qts .qm files, this script does that for +# linux and macos, windeployqt does this for windows. +# https://doc.qt.io/qt-5/linguist-programmers.html#deploying-translations +# +# This script is created from the log of the windows build from windeployqt +# with Qt 5.12.1. +# From the log you can see which translation files are used which depends on +# which Qt modules we use. +# In our case these are qtbase_*.qm, qtdeclarative_*qm and qtserialport_*.qm. +# +# Note with Qt5 the Qt distributed qt_xx.qm files are metacatalogs, and just +# copying or converting them won't copy the dependencies. + + if [ "${machine}" = "Mac" ]; then + resourcedir="${APPDIR}/Contents/Resources" + + # caution, mktemp here is macos specific version + resourceskel="$(mktemp -t gpsbabel_package_app)" + echo '' > "$resourceskel" + echo '> "$resourceskel" + echo '"http://www.apple.com/DTDs/PropertyList-1.0.dtd">' >> "$resourceskel" + echo '' >> "$resourceskel" + echo '' >> "$resourceskel" + echo ' LprojCompatibleVersion' >> "$resourceskel" + echo ' 123' >> "$resourceskel" + echo ' LprojLocale' >> "$resourceskel" + echo ' LANGUAGE' >> "$resourceskel" + echo ' LprojRevisionLevel' >> "$resourceskel" + echo ' 1' >> "$resourceskel" + echo ' LprojVersion' >> "$resourceskel" + echo ' 123' >> "$resourceskel" + echo '' >> "$resourceskel" + echo '' >> "$resourceskel" + fi + + pushd "$(${QMAKE} -query QT_INSTALL_TRANSLATIONS)" > /dev/null + languages=($(echo qtbase_??.qm | sed 's/qtbase_\(..\).qm/\1/g')) + for language in "${languages[@]}" + do + inputs=() + inputs+=("qtbase_${language}.qm") + if [ -e "qtdeclarative_${language}.qm" ]; then inputs+=("qtdeclarative_${language}.qm"); fi + if [ -e "qtserialport_${language}.qm" ]; then inputs+=("qtserialport_${language}.qm"); fi + "${LCONVERT}" -o "${LANGDIR}/qt_${language}.qm" "${inputs[@]}" + + if [ "${machine}" = "Mac" ]; then + # Create locversion.plist in the bundle to trigger translations for + # the application menu and system buttons. See description at + # https://doc.qt.io/qt-5/macos-issues.html#translating-the-application-menu-and-native-dialogs + mkdir -p "${resourcedir}/${language}.lproj" + sed "s/LANGUAGE/${language}/" "${resourceskel}" > "${resourcedir}/${language}.lproj/locversion.plist" + fi + done + popd > /dev/null + + if [ "${machine}" = "Mac" ]; then + rm "${resourceskel}" + fi +} + +QMAKE="${QMAKE:-qmake}" + +LUPDATE="$(${QMAKE} -query QT_INSTALL_BINS)/lupdate" +LRELEASE="$(${QMAKE} -query QT_INSTALL_BINS)/lrelease" +LCONVERT="$(${QMAKE} -query QT_INSTALL_BINS)/lconvert" +MACDEPLOYQT="$(${QMAKE} -query QT_INSTALL_BINS)/macdeployqt" + +case "$(uname -s)" in + Linux*) machine=Linux;; + Darwin*) machine=Mac;; + *) echo "Unknown kernel name $(uname -s)." 1>&2; exit 1;; +esac + +# update our translations and compile them. +"${LUPDATE}" app.pro +"${LRELEASE}" app.pro + +if [ "${machine}" = "Linux" ]; then + # need absolute paths for convert_qt_translations() + APPDIR="$(pwd)/GPSBabelFE" + LANGDIR="${APPDIR}/translations" +else + APPBUNDLE=GPSBabelFE.app + # need absolute paths for convert_qt_translations() + APPDIR="$(pwd)/${APPBUNDLE}" + LANGDIR="${APPDIR}/Contents/MacOS/translations" +fi + +rm -fr "${LANGDIR}" +mkdir -p "${LANGDIR}" + +# copy our compiled translations. +cp gpsbabelfe_??.qm "${LANGDIR}" + +# bundle Qt .qm files, deploy them with our .qm files, +# and, for macos, make & deploy locversion.plist files. +(convert_qt_translations) + +if [ "${machine}" = "Linux" ]; then + cp objects/gpsbabelfe "${APPDIR}" + cp ../gpsbabel "${APPDIR}" + cp gmapbase.html "${APPDIR}" + cp COPYING.txt "${APPDIR}" +else # Mac + cp ../GPSBabel "${APPDIR}/Contents/MacOS/gpsbabel" + cp gmapbase.html "${APPDIR}/Contents/MacOS" + cp COPYING.txt "${APPDIR}/Contents/MacOS" + rm -f objects/GPSBabelFE.dmg + # macdeploytqt likes relative paths or else the dmg mount points get funky. + "${MACDEPLOYQT}" "${APPBUNDLE}" -executable="${APPBUNDLE}/Contents/MacOS/gpsbabel" -dmg -verbose=2 +fi diff --git a/gui/setup.iss b/gui/setup.iss index 4b8e163f5..ffdac03d9 100644 --- a/gui/setup.iss +++ b/gui/setup.iss @@ -1,5 +1,5 @@ ; -; NOTE: setup.iss is generated from setup.iss.in via autoconf. +; NOTE: setup.iss is generated from setup.iss.in via configure. ; The generated setup.iss is checked in to help keep the version numbers ; synchronized. ; @@ -58,7 +58,7 @@ Source: "..\..\{#gpsbabel_build_dir_name}\release\gpsbabel.exe"; DestDir: "{a ; Compiled translation strings that are used at runtime. ; Source: gpsbabel_*.qm; DestDir: "{app}\translations"; Flags: ignoreversion -Source: gpsbabelfe*.qm; DestDir: "{app}\translations"; Flags: ignoreversion +Source: gpsbabelfe_*.qm; DestDir: "{app}\translations"; Flags: ignoreversion ; Miscellaneous Source: COPYING.txt; DestDir: {app}; Flags: ignoreversion diff --git a/gui/setup.iss.in b/gui/setup.iss.in index f884fee29..9cf5df215 100755 --- a/gui/setup.iss.in +++ b/gui/setup.iss.in @@ -1,5 +1,5 @@ ; -; NOTE: setup.iss is generated from setup.iss.in via autoconf. +; NOTE: setup.iss is generated from setup.iss.in via configure. ; The generated setup.iss is checked in to help keep the version numbers ; synchronized. ; @@ -58,7 +58,7 @@ Source: "..\..\{#gpsbabel_build_dir_name}\release\gpsbabel.exe"; DestDir: "{a ; Compiled translation strings that are used at runtime. ; Source: gpsbabel_*.qm; DestDir: "{app}\translations"; Flags: ignoreversion -Source: gpsbabelfe*.qm; DestDir: "{app}\translations"; Flags: ignoreversion +Source: gpsbabelfe_*.qm; DestDir: "{app}\translations"; Flags: ignoreversion ; Miscellaneous Source: COPYING.txt; DestDir: {app}; Flags: ignoreversion diff --git a/tools/mac-localize b/tools/mac-localize deleted file mode 100755 index 8fa5d89b0..000000000 --- a/tools/mac-localize +++ /dev/null @@ -1,29 +0,0 @@ -# Create locversion.plist in the bundle to trigger translations for -# the application menu and system buttons. See description at -# http://doc.qt.nokia.com/4.6/mac-differences.html#translating-the-application-menu-and-native-dialogs - -QTDIR=`qmake -query QT_INSTALL_TRANSLATIONS` - -LANGDIR=objects/GPSBabelFE.app/Contents/MacOS/translations - - -mkplist() { - D=objects/GPSBabelFE.app/Contents/Resources/$1.lproj - [ ! -d $D ] && mkdir $D - sed "s/LANGUAGE/$1/" ../tools/skeleton-locversion-plist > $D/locversion.plist - # optional as en, it, and hu aren't translated in Qt yet. - [ ! -f "$QTDIR/qt_$1.qm" ] && echo "Bad QTDIR for $1" - [ -f "$QTDIR/qt_$1.qm" ] && cp "$QTDIR/qt_$1.qm" $LANGDIR - [ -f gpsbabelfe_${1}.qm ] && cp gpsbabelfe_${1}.qm $LANGDIR -} - -cd gui -[ ! -d $LANGDIR ] && mkdir $LANGDIR -for i in $(echo gpsbabelfe_??.ts | sed 's/gpsbabelfe_\(..\).ts/\1/g') -do - mkplist $i -done - -mkplist en - -exit 0 diff --git a/tools/skeleton-locversion-plist b/tools/skeleton-locversion-plist deleted file mode 100644 index 0b71e7c0d..000000000 --- a/tools/skeleton-locversion-plist +++ /dev/null @@ -1,15 +0,0 @@ - - - - - LprojCompatibleVersion - 123 - LprojLocale - LANGUAGE - LprojRevisionLevel - 1 - LprojVersion - 123 - - diff --git a/tools/travis_script_osx b/tools/travis_script_osx index b10ab5244..98a3e2cbf 100755 --- a/tools/travis_script_osx +++ b/tools/travis_script_osx @@ -19,28 +19,14 @@ $QMAKE GPSBabel.pro && make -j 2 && make check # build the GUI pushd gui $QMAKE app.pro && make -j 2 -$LUPDATE app.pro -$LRELEASE app.pro -popd - -# package the app -mkdir -p gui/objects/GPSBabelFE.app/Contents/MacOS/translations -cp gui/*.qm gui/objects/gpsbabelFE.app/Contents/MacOS/translations -cp GPSBabel gui/objects/GPSBabelFE.app/Contents/MacOS/gpsbabel -cp gui/gmapbase.html gui/objects/GPSBabelFE.app/Contents/MacOS -cp gui/COPYING.txt gui/objects/GPSBabelFE.app/Contents/MacOS -tools/mac-localize - -rm -f gui/objects/GPSBabelFE.dmg -pushd gui/objects -$MACDEPLOYQT GPSBabelFE.app -executable=GPSBabelFE.app/Contents/MacOS/gpsbabel -dmg -verbose=2 +make package popd # what is in there? -hdiutil attach -noverify gui/objects/GPSBabelFE.dmg +hdiutil attach -noverify gui/GPSBabelFE.dmg find /Volumes/GPSBabelFE -ls hdiutil detach /Volumes/GPSBabelFE -mv gui/objects/GPSBabelFE.dmg gui/objects/GPSBabel-${VERSIONID}.dmg +mv gui/GPSBabelFE.dmg gui/GPSBabel-${VERSIONID}.dmg